package com.hznu.stmanage.serviceImpl;

import com.hznu.stmanage.dao.DiaryMapper;
import com.hznu.stmanage.entity.Diary;
import com.hznu.stmanage.service.BaseService;
import com.hznu.stmanage.service.DiaryService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by J_Vino on 16/3/6.
 */
@Transactional(rollbackFor=Exception.class)
@Service
public class DiaryServiceImpl extends BaseService implements DiaryService {

    DiaryMapper diaryMapper = null;
    public void setMapper()
    {
        if(diaryMapper==null)
            diaryMapper = getDiaryMapper();//1.获取相关mapper
    }

    public int deleteByPrimaryKey(Long id) {
        setMapper();
        return diaryMapper.deleteByPrimaryKey(id);
    }

    public int insert(Diary record) {
        setMapper();
        return diaryMapper.insert(record);
    }

    public int insertSelective(Diary record) {
        setMapper();
        return diaryMapper.insertSelective(record);
    }

    public Diary selectByPrimaryKey(Long id) {
        setMapper();
        return diaryMapper.selectByPrimaryKey(id);
    }

    public int updateByPrimaryKeySelective(Diary record) {
        setMapper();
        return diaryMapper.updateByPrimaryKeySelective(record);
    }

    public int updateByPrimaryKey(Diary record) {
        setMapper();
        return diaryMapper.updateByPrimaryKey(record);
    }
}
